package lumis.service.navigation;

import lumis.doui.source.IDataProvider;
import lumis.doui.source.ISourceData;
import lumis.doui.source.Source;
import lumis.portal.PortalException;
import lumis.portal.UnexpectedException;
import lumis.portal.authentication.SessionConfig;
import lumis.portal.manager.ManagerFactory;
import lumis.util.ITransaction;

/**
 * Returns properties for a bread crumb interface
 *
 * @version $Revision: 7370 $ $Date: 2007-06-12 13:50:49 -0300 (Tue, 12 Jun 2007) $
 * @since 4.0.11
 */
public class BreadCrumbPropertiesDataProvider implements IDataProvider
{
	public static final String SERVICE_INTERFACE_INSTANCE_PROPERTY_INCLUDE_HIDDEN_CHANNEL = "breadcrumb_includeHiddenChannels";
	
	public void loadData(SessionConfig sessionConfig, Source source, ITransaction transaction) throws PortalException
	{
		try
		{
			String callerInterfaceInstanceId = source.getDouiContext().getRequest().getCallerServiceInterfaceInstanceId();
			String includeHiddenChannels = ManagerFactory.getServiceInterfaceInstanceManager().getCustomProperty(sessionConfig, callerInterfaceInstanceId, SERVICE_INTERFACE_INSTANCE_PROPERTY_INCLUDE_HIDDEN_CHANNEL, transaction);
			ISourceData sourceData = source.getData();
			sourceData.put("includeHiddenChannels", "true".equals(includeHiddenChannels));
		}
		catch (PortalException e)
		{
			throw e;
		}
		catch (Exception e)
		{
			throw new UnexpectedException(e);
		}
	}
}
